package tmp.antlr;

import java.util.List;

import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;

import a3.JsonLexer;
import a3.JsonParser;
import a3.JsonParser.Bracket_bodyContext;
import a3.JsonParser.ExprContext;

public class Test3 {

	public static void main(String[] args)throws Exception {
//		run("/data/log/odin_tw_prod_0/repos_record.log.11:2014-12-24 12:12:07,174 [80000001343695][OUT][OdinReposKey [type=9, id=453005, level=0, serverId=10012938]amount:-1][{\"resourceVo\":{\"type\":9,\"id\":10012938,\"level\":0,\"amount\":1},\"method\":\"exchangeHonour\"}]");
		run("/data/log/odin_tw_prod_0/repos_record.log.33:2014-12-22 15:07:07,439 [80000001343695][Card][[resourceLogic]][metaId:43902101,amount:1][{\"gameStatus\":1,\"skillCaster\":{\"teamId\":1,\"fighterType\":1,\"fighterId\":46,\"petEffect\":true},\"skillSeq\":6,\"hitPoint\":{\"row\":13,\"col\":28},\"targetFighterList\":[{\"teamId\":2,\"fighterType\":2,\"fighterId\":87,\"petEffect\":false},{\"teamId\":2,\"fighterType\":2,\"fighterId\":92,\"petEffect\":false},{\"teamId\":2,\"fighterType\":2,\"fighterId\":86,\"petEffect\":false},{\"teamId\":2,\"fighterType\":4,\"fighterId\":2043011027,\"petEffect\":false},{\"teamId\":2,\"fighterType\":2,\"fighterId\":88,\"petEffect\":false}],\"randomNum\":[4741,7578,7059,5095,9143,7843,777,6936,4874,765],\"targetFighterDecreaseHp\":[{\"first\":87,\"second\":56079},{\"first\":92,\"second\":56079},{\"first\":86,\"second\":56079},{\"first\":2043011027,\"second\":353676},{\"first\":88,\"second\":56079}],\"method\":\"castSkill\"}]");

	}
	
	public static void run(String expr)throws Exception{
		ANTLRInputStream in = new ANTLRInputStream(expr);
		JsonLexer lexer = new JsonLexer(in);
		CommonTokenStream tokens = new CommonTokenStream(lexer);
		JsonParser exprParser = new JsonParser(tokens);
		ExprContext exprContext = exprParser.expr();
		System.out.println(exprContext.getText());
		List<Bracket_bodyContext> list = exprContext.bracket_body();
		System.out.println(list.size());
		System.out.print(list.get(0).getText());
		System.out.println("  ====   " + list.get(0).ANY_CHAR().get(0).getText());
		System.out.print(list.get(1).getText());
		System.out.println("  ====   " + list.get(1).ANY_CHAR().get(0).getText());
		System.out.println(list.get(2).getText());
		System.out.println(list.get(3).getText());
		System.out.println(list.get(4).getText());
		
		System.out.println(exprContext.ANY_CHAR().getText());
	}

}
